//
//  TeacherDetailViewController.m
//  HTP
//
//  Created by admin on 15/11/3.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "TeacherDetailViewController.h"
#import <HYBLoopScrollView/HYBLoopScrollView.h>
#import "BuyOneByManyCourseVC.h"
#import "BuyOneByOneCourseVC.h"

#import "TeacherDetailPJV.h"

#import "TeacherViewModel.h"
#import "TeacherPJRecordModel.h"
#import "CourseModel.h"
#define SelfFrame CGSizeMake(ScreenWidth, 2000)
@interface TeacherDetailViewController ()<UIScrollViewDelegate>
@property (nonatomic,retain) UIImageView *teacherImg;

@property (nonatomic,retain) UILabel     *nameLbl;
@property (nonatomic,retain) UILabel     *goodLbl;
@property (nonatomic,strong) UILabel     *signLbl;
@property (nonatomic,strong) UILabel     *gradeLbl;

@property (nonatomic,retain) UILabel     *ageLbl;
@property (nonatomic,retain) UILabel     *timeLbl;
@property (nonatomic,retain) UILabel     *countLbl;

@property (nonatomic,strong) UIScrollView *backScrollView;

@property (nonatomic,strong) UIView        *detailV;
@property (nonatomic,strong) HYBLoopScrollView *teacherImages;
@property (nonatomic,strong) UIView        *courseV;
@property (nonatomic,strong) UIView        *teacherV;
@property (nonatomic,strong) UIView        *footV;
@property (nonatomic,strong) UIImageView   *bottomView;
@property (nonatomic,strong) UIImageView   *loveImg;//收藏图标
@property (nonatomic,strong) UILabel       *loveLabel;//收藏文字

@property (nonatomic,retain) TeacherModel *teacherDetail;
@property (nonatomic,retain) NSArray      *courseArrays;
@property (nonatomic,retain) NSArray      *recordArrays;
@property (nonatomic,retain) NSArray      *teacherImgArrays;
@end

@implementation TeacherDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.backScrollView];
    [self _initView_1];
    // Do any additional setup after loading the view.
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self getteacherDetail];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.view setBackgroundColor:RGBCOLOR(232, 229, 220, 1)];
    [self addCustomTitleWithTitle:@"教师详情"];
    [self addCustomBackBase];
}
//TODO:绘制UI
- (void)_initView_1{
    
    [self.backScrollView setFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeihgt - NavHe - 49)];
    
    _detailV = [[UIView alloc] init];
    [self initDetailV];
    [self.backScrollView addSubview:_detailV];
    
    
    _courseV = [[UIView alloc] init];
    [self.backScrollView addSubview:_courseV];
    
    
    _teacherV = [[UIView alloc] init];
    [self.backScrollView addSubview:_teacherV];
    
    
    _footV = [[UIView alloc] init];
    [self.backScrollView addSubview:_footV];
    
    _bottomView = [[UIImageView alloc] initWithFrame:CGRectMake(0, ScreenHeihgt - NavHe -49, ScreenWidth, 49)];
    _bottomView.userInteractionEnabled = YES;
    [self.view addSubview:_bottomView];
    
}
/**
 *  初始化detailView
 */
- (void)initDetailV{
    
    _teacherImages = [HYBLoopScrollView loopScrollViewWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth / 5 * 3) imageUrls:[[NSArray alloc] initWithObjects:@"m_teacher_b", nil]];
    [_teacherImages setBackgroundColor:[UIColor clearColor]];
    _teacherImages.placeholder = [UIImage imageNamed:@"m_teacher_m"];
    [_detailV addSubview:_teacherImages];
    
    _nameLbl = [self getNormolLabel];
    _nameLbl.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:18];
    _nameLbl.textColor = [UIColor blackColor];
    [self.detailV addSubview:_nameLbl];
    
    _goodLbl = [self getNormolLabel];
    [self.detailV addSubview:_goodLbl];
    
    _gradeLbl = [self getNormolLabel];
    [self.detailV addSubview:_gradeLbl];
    
    _signLbl = [self getNormolLabel];
    [_signLbl setTextColor:[UIColor blackColor]];
    [self.detailV addSubview:_signLbl];

}
- (void)initTeacherV{
    
}
- (void)_initView{
    [self.view addSubview:self.backScrollView];
    [self.backScrollView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-49);
    }];
    _teacherImg = [[UIImageView alloc] init];
    [_teacherImg setBackgroundColor:[UIColor redColor]];
    [self.backScrollView addSubview:_teacherImg];
    [_teacherImg makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(0);
        make.left.equalTo(10);
        make.width.equalTo(self.backScrollView).offset(-20);
        make.height.equalTo(self.backScrollView.width).multipliedBy(2.0/3.0);
    }];
    
    UIImageView *imageLine = [[UIImageView alloc] init];
    [imageLine setImage:[UIImage imageNamed:@"teacher_h"]];
    [imageLine setBackgroundColor:RGBCOLOR(177, 177, 177, 0.6)];
    [self.backScrollView addSubview:imageLine];
    [imageLine makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_teacherImg.bottom).offset(10);
        make.left.and.right.equalTo(self.view);
        make.height.equalTo(2);
    }];
    
    _nameLbl = [self getNormolLabel];
    _nameLbl.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:18];
    _nameLbl.textColor = [UIColor blackColor];
    _nameLbl.backgroundColor = [UIColor yellowColor];
    [self.backScrollView addSubview:_nameLbl];
    [_nameLbl makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imageLine.bottom).offset(20);
        make.left.equalTo(0);
        make.width.equalTo(imageLine);
    }];
    _goodLbl = [self getNormolLabel];
    [self.backScrollView addSubview:_goodLbl];
    [_goodLbl makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLbl.bottom).offset(15);
        make.left.and.right.equalTo(self.backScrollView);
    }];

    _signLbl = [self getNormolLabel];
    [_signLbl setTextColor:[UIColor blackColor]];
    [self.backScrollView addSubview:_signLbl];
    [_signLbl makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_goodLbl.bottom).offset(10);
        make.left.and.right.equalTo(self.view);
    }];

    UIImageView *imageLine_1 = [[UIImageView alloc] init];
    [imageLine_1 setImage:[UIImage imageNamed:@"teacher_h"]];
    [imageLine_1 setBackgroundColor:RGBCOLOR(177, 177, 177, 0.9)];
    [self.backScrollView addSubview:imageLine_1];
    [imageLine_1 makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_signLbl.bottom).offset(10);
        //        make.width.equalTo(_teacherImg);
        make.left.and.right.equalTo(self.view);
        make.height.equalTo(2);
    }];
    
    _ageLbl = [self getNormolLabel];
    _ageLbl.textAlignment = _TEXT_ALIGN_LEFT;
    [self.backScrollView addSubview:_ageLbl];
    [_ageLbl makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(20);
        make.right.equalTo(self.backScrollView).offset(-20);
        make.top.equalTo(imageLine_1.bottom).offset(15);
    }];
    _timeLbl = [self getNormolLabel];
    _timeLbl.textAlignment = _TEXT_ALIGN_LEFT;
    [self.backScrollView addSubview:_timeLbl];
    [_timeLbl makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_ageLbl);
        make.top.equalTo(_ageLbl.bottom).offset(10);
    }];
    _countLbl = [self getNormolLabel];
    _countLbl.textAlignment = _TEXT_ALIGN_LEFT;
    [self.backScrollView addSubview:_countLbl];
    [_countLbl makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_ageLbl);
        make.top.equalTo(_timeLbl.bottom).offset(10);
    }];
    UIButton *contactBtn = [[UIButton alloc] init];
    [contactBtn setTitle:@"联系老师" forState:UIControlStateNormal];
    [contactBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [contactBtn.titleLabel setFont:[UIFont systemFontOfSize:23]];
    [self.view addSubview:contactBtn];
    [contactBtn makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view);
        make.bottom.equalTo(self.view);
        make.height.equalTo(49);
        make.width.equalTo(self.backScrollView.width).multipliedBy(0.5).offset(-0.5);
    }];
    
    UIButton *applyBtn = [[UIButton alloc] init];
    [applyBtn setTitle:@"立即报名" forState:UIControlStateNormal];
    [applyBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [applyBtn.titleLabel setFont:[UIFont systemFontOfSize:23]];
    [self.view addSubview:applyBtn];
    [applyBtn makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view);
        make.bottom.equalTo(self.view);
        make.height.equalTo(49);
        make.width.equalTo(self.backScrollView.width).multipliedBy(0.5).offset(-0.5);
    }];
    
    UIImageView *line_s = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"teacher_s"]];
    [line_s setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:line_s];
    [line_s makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(contactBtn.right);
        make.bottom.equalTo(self.view).offset(-10);
        make.width.equalTo(1);
        make.height.equalTo(29);
    }];
}

//TODO:重写get方法
- (UIScrollView *)backScrollView{
    if (!_backScrollView) {
        _backScrollView = [[UIScrollView alloc] init];
        _backScrollView.backgroundColor = [UIColor whiteColor];
        _backScrollView.userInteractionEnabled = YES;
        _backScrollView.delegate = self;
    }
    return _backScrollView;
}
//TODO:action
- (void)signCourse:(id)sender{
    UIButton *btn = (UIButton *)sender;
    NSInteger  tag = btn.tag;
    CourseModel *course = [_courseArrays objectAtIndex:tag];
    course.teacherName = _teacherDetail.userNickName;
    if ([course.tsType integerValue] == 0) {
        BuyOneByOneCourseVC *buyOneByOneVc = [[BuyOneByOneCourseVC alloc] init];
        buyOneByOneVc.courseM = course;
        [self.navigationController pushViewController:buyOneByOneVc animated:YES];
    }else{
        BuyOneByManyCourseVC *buyOneByManyVc = [[BuyOneByManyCourseVC alloc] init];
        buyOneByManyVc.courseM = course;
        [self.navigationController pushViewController:buyOneByManyVc animated:YES];
    }
}

/**
 *  uiscrollView 定位到课程
 */
- (void)showCourseCenter{
    [UIView animateWithDuration:0.5 animations:^{
        self.backScrollView.contentOffset = CGPointMake(0, CGRectGetMaxY(_detailV.frame));
    }];
}
/**
 *  获取教师详情
  */
- (void)getteacherDetail{
    TeacherViewModel *teacherVM = [[TeacherViewModel alloc] init];
    [teacherVM setBlockWithReturnBlock:^(id returnValue) {
        [self hiddenMbProgress];
        [self getData:(NSDictionary *)returnValue];
        [self setViewData];
    } WithErrorBlock:^(id errorCode) {
        [self hiddenMbProgress];
    } WithFailureBlock:^{
        [self hiddenMbProgress];
    }];
    [self showMbProgress:@""];
    [teacherVM getTeacherInfoByTeacherId:[NSString stringWithFormat:@"%@",_teacherId]];
}
- (void)getData:(NSDictionary *)messgae{
    NSString *achieve = messgae[@"Achieve"];
    
    _courseArrays = [CourseModel mj_objectArrayWithKeyValuesArray:messgae[@"Course"]];
    _recordArrays = [TeacherPJRecordModel mj_objectArrayWithKeyValuesArray:messgae[@"Record"]];
    _teacherDetail = [TeacherModel mj_objectWithKeyValues:messgae[@"TeacherDetail"]];
    _teacherDetail.isZan = messgae[@"isZan"];
    _teacherDetail.isSC = messgae[@"isSC"];
    NSArray *images = [achieve componentsSeparatedByString:@"#"];
    [images enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSString *str = (NSString *)obj;
        if ([str isContainsString:@"http"]) {
            
        }else{
            str = [NSString stringWithFormat:@"%@%@",IMAGEHTTP,obj];
        }
    }];
    _teacherImgArrays = images;
    if ([achieve isEqualToString:@""]) {
        _teacherImgArrays = [NSArray arrayWithObject:_teacherDetail.userPhoto.length == 0 ? @"m_teacher_b":[_teacherDetail.userPhoto addHTTPImageHead:_teacherDetail.userPhoto]];
    }
}
//TODO:获取数据后绘制画面方法
- (void)setViewData{
    [self setViewDataDetailV];
    
    [self setViewDataCourse];
    
    [self setViewDataTeacherV];
    
    [self setViewDataPL];
    
    [self.backScrollView setContentSize:CGSizeMake(ScreenWidth, CGRectGetMaxY(_footV.frame)+10)];
    [self setViewDataBootomView];
}
/**
 *  根据数据初始化教师详情
 */
- (void)setViewDataDetailV{
    _nameLbl.text = _teacherDetail.userNickName;
    _goodLbl.text = _teacherDetail.tchMajor;
    _signLbl.text = _teacherDetail.tchMotto;
    _gradeLbl.text = _teacherDetail.teacherGoodAt;
    
    [_teacherImages setImageUrls:_teacherImgArrays];
    
    [_nameLbl setFrame:CGRectMake(0, CGRectGetMaxY(_teacherImages.frame) + 10, ScreenWidth, [_nameLbl.text textSizeWithFont:[UIFont fontWithName:@"Helvetica-BoldOblique" size:18] constrainedSize:SelfFrame].height)];
    
    [_goodLbl setFrame:CGRectMake(0, CGRectGetMaxY(_nameLbl.frame) + (CGRectGetHeight(_nameLbl.frame) > 0 ? 10:0), ScreenWidth, [_goodLbl.text textSizeWithFont:_goodLbl.font constrainedSize:SelfFrame].height)];
    if (_goodLbl.text.length == 0) {
        [_goodLbl setFrame:CGRectMake(_goodLbl.frame.origin.x, CGRectGetMinY(_goodLbl.frame), 0, 0)];
    }
    [_gradeLbl setFrame:CGRectMake(0, CGRectGetMaxY(_goodLbl.frame) +(CGRectGetHeight(_goodLbl.frame) > 0 ? 10:0), ScreenWidth, [_gradeLbl.text textSizeWithFont:_gradeLbl.font constrainedSize:SelfFrame].height)];
    if (_gradeLbl.text.length == 0) {
        [_gradeLbl setFrame:CGRectMake(_gradeLbl.frame.origin.x, CGRectGetMinY(_gradeLbl.frame), 0, 0)];
    }
    [_signLbl setFrame:CGRectMake(0, CGRectGetMaxY(_gradeLbl.frame) + (CGRectGetHeight(_gradeLbl.frame) > 0 ? 10:0), ScreenWidth, [_signLbl.text textSizeWithFont:_signLbl.font constrainedSize:SelfFrame].height)];
    if (_signLbl.text.length == 0) {
        [_signLbl setFrame:CGRectMake(_signLbl.frame.origin.x, CGRectGetMinY(_signLbl.frame), 0, 0)];
    }
    UIImageView *lineView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line_h"]];
    [lineView setFrame:CGRectMake(20, CGRectGetMaxY(_signLbl.frame)+ 15, ScreenWidth - 40, 1)];
    [_detailV addSubview:lineView];
    
    [_detailV setFrame:CGRectMake(0, 0, ScreenWidth, CGRectGetMaxY(_signLbl.frame) + 16)];
}
/**
 *  初始化课程列表
 */
- (void)setViewDataCourse{
    [_courseV.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj removeFromSuperview];
    }];
    for(int i = 0 ; i < _courseArrays.count ; i ++){
        CourseModel *courseModel = [_courseArrays objectAtIndex:i];
        UIView *course = [self setOneCourseView:courseModel withTag:i];
        [course setFrame:CGRectMake(0,35 +  30 * i, ScreenWidth, 30)];
        [_courseV addSubview:course];
    }
    UILabel *detail = [self getNormolLabel];
    detail.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:20];
    detail.textColor = [UIColor blackColor];
    detail.text = @"课程";
    [detail setFrame:CGRectMake(0, 0, ScreenWidth, 30)];
    [_courseV addSubview:detail];
    
    UIImageView *lineView_1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line_h"]];
    [lineView_1 setFrame:CGRectMake(20, _courseArrays.count * 30 + 59, ScreenWidth - 40, 1)];
    [_courseV addSubview:lineView_1];
    [_courseV setFrame:CGRectMake(0, CGRectGetMaxY(_detailV.frame)+20, ScreenWidth, _courseArrays.count * 30 + 35 + 25)];
    
    if (_courseArrays.count == 0) {
        [_courseV.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            [obj removeFromSuperview];
        }];
        [_courseV setFrame:CGRectMake(0, CGRectGetMaxY(_detailV.frame)+20, ScreenWidth,0)];
    }
}
- (UIView *)setOneCourseView:(CourseModel *)courseModel withTag:(int) tag{
    UIView *courseOne = [[UIView alloc] init];
    courseOne.userInteractionEnabled = YES;
    UILabel *courseName = [self getNormolLabel];
    [courseName setText:[NSString stringWithFormat:@"%@%@",courseModel.grade,courseModel.course]];
    CGSize nameSize = [courseName.text textSizeWithFont:courseName.font constrainedSize:CGSizeMake(ScreenWidth / 2.0-20, 25)];
    [courseName setFrame:CGRectMake(20, 5, nameSize.width, nameSize.height)];
    [courseOne addSubview:courseName];
    
    UILabel *pricesLaebl = [self getNormolLabel];
    pricesLaebl.font = [UIFont systemFontOfSize:13];
    pricesLaebl.textColor = [UIColor orangeColor];
    [pricesLaebl setText:[NSString stringWithFormat:@"%.2lf元/小时",[courseModel.tsPrice floatValue]]];
    CGSize priceSize = [pricesLaebl.text textSizeWithFont:pricesLaebl.font constrainedSize:CGSizeMake(ScreenWidth / 2.0-20 - 40, 25)];
    [pricesLaebl setFrame:CGRectMake(ScreenWidth / 2.0, 5, priceSize.width, priceSize.height)];
    [courseOne addSubview:pricesLaebl];
    
    UIButton *signBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth - 60, 2.5, 40, 20)];
    [signBtn setBackgroundImage:[UIImage imageNamed:@"baoming"] forState:UIControlStateNormal];
    signBtn.tag = tag;
    [signBtn addTarget:self action:@selector(signCourse:) forControlEvents:UIControlEventTouchUpInside];
    [courseOne addSubview:signBtn];

    return courseOne;
}
/**
 *根据数据初始化TeacherDetailV
 */
- (void)setViewDataTeacherV{
    [_teacherV.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj removeFromSuperview];
    }];
    
    UIView *view_1 = [self setOneTeacherView:CGRectMake(20, 25, (ScreenWidth -40)/ 5.0 , ScreenWidth / 5.0 * 1.8 + 50) imageName:@"shichang" text_1:[NSString stringWithFormat:@"%@个",_teacherDetail.tchTeachYears] text_2:@"教龄"];
    [_teacherV addSubview:view_1];
    
    UIView *view_2 = [self setOneTeacherView:CGRectMake(20+ (ScreenWidth -40)/ 5.0, 25, (ScreenWidth -40)/ 5.0 ,ScreenWidth / 5.0 * 1.6 ) imageName:@"stu" text_1:[NSString stringWithFormat:@"%@个",_teacherDetail.sumStu] text_2:@"学生数"];
    [_teacherV addSubview:view_2];
    
    UIView *view_3 = [self setOneTeacherView:CGRectMake(20+ (ScreenWidth -40)/ 5.0*2.0, 25, (ScreenWidth -40)/ 5.0, ScreenWidth / 5.0 * 1.6 ) imageName:@"jinqi" text_1:[NSString stringWithFormat:@"%@个",_teacherDetail.tchFlagCount] text_2:@"锦旗"];
    [_teacherV addSubview:view_3];
    
    
    UIView *view_4 = [self setOneTeacherView:CGRectMake(20+ (ScreenWidth -40)/ 5.0 * 3.0, 25, (ScreenWidth -40)/ 5.0, ScreenWidth / 5.0 * 1.6 ) imageName:@"shijian" text_1:[NSString stringWithFormat:@"%@h",_teacherDetail.sumTime] text_2:@"授课时长"];
    [_teacherV addSubview:view_4];
    
    NSString *imgStr = @"";
    if ([_teacherDetail.isZan intValue] == 0) {
        imgStr = @"zan";
    }else if ([_teacherDetail.isZan intValue] == 1){
        imgStr = @"zaned";
    }
    
    UIView *view_5 = [self setOneTeacherView:CGRectMake(20+ (ScreenWidth -40)/ 5.0 * 4.0, 25, (ScreenWidth -40)/ 5.0, ScreenWidth / 5.0 * 1.6 ) imageName:imgStr text_1:[NSString stringWithFormat:@"%@个",_teacherDetail.tchPraiseCount] text_2:@"赞"];
    [view_5 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addZan)]];
    [_teacherV addSubview:view_5];
    
    UIImageView *lineView_1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line_h"]];
    [lineView_1 setFrame:CGRectMake(20, CGRectGetMaxY(view_5.frame), ScreenWidth - 40, 1)];
    [_teacherV addSubview:lineView_1];
    [_teacherV setFrame:CGRectMake(0, CGRectGetMaxY(_courseV.frame), ScreenWidth, ScreenWidth / 5.0 * 1.6 + 25+1)];
}
- (UIView *)setOneTeacherView:(CGRect)frame imageName:(NSString *)name text_1:(NSString *)text_1 text_2:(NSString *)text_2{
    UIView *view = [[UIView alloc] initWithFrame:frame];
    CGFloat width = frame.size.width;
    CGFloat imageWidth = (ScreenWidth -40)/ 10.0;
    
    UIImageView *titleImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:name]];
    titleImg.contentMode = UIViewContentModeScaleAspectFit;
    [titleImg setFrame:CGRectMake((width - imageWidth) / 2.0, 0, imageWidth, imageWidth)];
    [view addSubview:titleImg];
    
    UILabel *detail = [self getNormolLabel];
    detail.font = [UIFont systemFontOfSize:15];
    detail.textAlignment = _TEXT_ALIGN_CENTER;
    detail.text = text_1;
    [detail setFrame:CGRectMake(0, CGRectGetMaxY(titleImg.frame)+5, width, ScreenWidth / 5.0 * 0.6 / 2.0)];
    [view addSubview:detail];
    
    UILabel *title = [self getNormolLabel];
    title.font = [UIFont systemFontOfSize:10];
    title.textAlignment = _TEXT_ALIGN_CENTER;
    title.text = text_2;
    [title setFrame:CGRectMake(0, CGRectGetMaxY(detail.frame), width, ScreenWidth / 5.0 * 0.6 / 2.0)];
    [view addSubview:title];
    
    return view;
}
//
- (void)setViewDataPL{
    [_footV.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj removeFromSuperview];
    }];
    UILabel *parentPJ = [self getNormolLabel];
    parentPJ.textAlignment = _TEXT_ALIGN_LEFT;
    [parentPJ setFrame:CGRectMake(10, 10, ScreenWidth - 110, 20)];
    parentPJ.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:20];
    parentPJ.text = @"家长评价";
    [_footV addSubview:parentPJ];
    
    UIButton *allPJ = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth - 110, 15, 90, 15)];
    [allPJ setTitle:@"查看所有评论" forState:UIControlStateNormal];
    [allPJ setTitleColor:RGBCOLOR(0, 0, 0, 0.8) forState:UIControlStateNormal];
    [allPJ.titleLabel setFont:[UIFont systemFontOfSize:12]];
    [_footV addSubview:allPJ];
    CGFloat heee = 80;
    for (int i = 0 ; i < _recordArrays.count; i++) {
        if (i > 1) {
            break;
        }else{
            TeacherDetailPJV *teach = [[TeacherDetailPJV alloc] init];
            if (i == _recordArrays.count -1 || i == 1) {
                teach.isLast = YES;
            }
            CGFloat he = [teach TeacherPJRecordModel:[_recordArrays objectAtIndex:i]];
            [teach setFrame:CGRectMake(0, heee, ScreenWidth, he)];
            [_footV addSubview:teach];
            heee+=he+10;
        }
    }
    [_footV setFrame:CGRectMake(0, CGRectGetMaxY(_teacherV.frame), ScreenWidth, heee)];
    if (_recordArrays.count == 0) {
        [_footV.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            [obj removeFromSuperview];
        }];
        [_footV setFrame:CGRectMake(0, CGRectGetMaxY(_teacherV.frame), ScreenWidth, 0)];
    }
}
- (void)setViewDataBootomView{
    [_bottomView setImage:[UIImage imageNamed:@"bg_yuyue"]];
    [_bottomView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj removeFromSuperview];
    }];
    
    UIImageView *imageContact = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 49)];
    [imageContact setImage:[UIImage imageNamed:@"lianxi"]];
    [_bottomView addSubview:imageContact];
    
    
    _loveImg = [[UIImageView alloc] initWithFrame:CGRectMake(70, 10, 30, 20)];
    _loveImg.contentMode = UIViewContentModeScaleAspectFit;
    if ([_teacherDetail.isSC integerValue]) {
        [_loveImg setImage:[UIImage imageNamed:@"yishoucang"]];
    } else{
        [_loveImg setImage:[UIImage imageNamed:@"weishoucang"]];
    }
    
    [_bottomView addSubview:_loveImg];
    
    UIButton *addSCBtn = [[UIButton alloc] initWithFrame:CGRectMake(60, 0, 40, 49)];
    [_bottomView addSubview:addSCBtn];
    [addSCBtn addTarget:self action:@selector(addSC) forControlEvents:UIControlEventTouchUpInside];
    
    _loveLabel = [self getNormolLabel];
    _loveLabel.textAlignment = _TEXT_ALIGN_CENTER;
    _loveLabel.font = [UIFont systemFontOfSize:10];
    [_loveLabel setText:@"收藏"];
    [_loveLabel setFrame:CGRectMake(60, 35, 49, 14)];
    [_bottomView addSubview:_loveLabel];
    
    UILabel *label = [self getNormolLabel];
    label.font = [UIFont systemFontOfSize:15];
    label.frame = CGRectMake(105, 20, 15, 15);
    label.text = @"￥";
    label.textAlignment = _TEXT_ALIGN_RIGHT;
    [_bottomView addSubview:label];
    
    
    
    NSString *PricesStr = _teacherDetail.pricesStr;

    
    UILabel *priceLaebl = [self getNormolLabel];
    priceLaebl.text = PricesStr;
    priceLaebl.font = [UIFont systemFontOfSize:17];
    priceLaebl.textAlignment = _TEXT_ALIGN_LEFT;
    [priceLaebl setFrame:CGRectMake(120, 11, ScreenWidth - 125 - 49, 30)];
    [_bottomView addSubview:priceLaebl];
    
    UIButton *yyBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth - 49, 0, 49, 49)];
    [yyBtn.titleLabel setFont:[UIFont systemFontOfSize:18]];
    [yyBtn setTitle:@"预约" forState:UIControlStateNormal];
    [yyBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [yyBtn addTarget:self action:@selector(showCourseCenter) forControlEvents:UIControlEventTouchUpInside];
    [_bottomView addSubview:yyBtn];
}

//TODO:action
- (void)addZan{
    if ([_teacherDetail.isZan integerValue] == 1) {
        [self showSVProgressSuccess:@"已经点赞"];
        return;
    }
    TeacherViewModel *teacherVM = [[TeacherViewModel alloc] init];
    [teacherVM setBlockWithReturnBlock:^(id returnValue) {
        NSNumber *result = returnValue[INTERFACE_INFO];
        if ([result integerValue] == -1) {
            [self showSVProgressFailed:@"您已经点赞"];
        }else{
            int  count = [_teacherDetail.tchPraiseCount intValue] + 1;
            _teacherDetail.tchPraiseCount = [NSNumber numberWithInt:count];
            _teacherDetail.isZan = [NSNumber numberWithInt:1];
            [self setViewDataTeacherV];
        }
        
    } WithErrorBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        
    }];
    [teacherVM addUserStore:_teacherDetail.userId userStoreType:[NSNumber numberWithInt:0]];
    
}
- (void)addSC{
    if ([_teacherDetail.isSC integerValue]) {
        return;
    }
    TeacherViewModel *teacherVM = [[TeacherViewModel alloc] init];
    [teacherVM setBlockWithReturnBlock:^(id returnValue) {
        NSNumber *result = returnValue[INTERFACE_INFO];
        if ([result integerValue] == -1) {
            [self showSVProgressFailed:@"您已经收藏"];
        }else{
            _teacherDetail.isSC = [NSNumber numberWithInt:1];
            [self setViewDataBootomView];
        }
        
    } WithErrorBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        
    }];
    [teacherVM addUserStore:_teacherDetail.userId userStoreType:[NSNumber numberWithInt:1]];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
